<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="text" id="id-number"><br>
    <button id="btn">显示生日</button><br>
    <input type="text" id="birthday" readonly>
    <script>
        var num = document.querySelector('#id-number');
        var btn = document.querySelector('#btn');
        var birth = document.querySelector('#birthday');
        btn.onclick = function() {
            var value = num.value.trim();
            if (value.length != 18) {
                alert("兄弟伙，是不是中国的！");
                return
            };
            var year = value.slice(6, 10);
            var month = value.slice(10, 12);
            var day = value.slice(12, 14);
            var birthday = `${year}年${month}月${day}日`;
            birth.value = birthday;
        };
    </script>
</body>

</html>